package state_and_station;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Solution {
    public static void main(String[] args) {
        // 用来存储所需要的覆盖的州
        HashSet<String> states_needed = new HashSet<>();
        states_needed.add("mt");
        states_needed.add("wa");
        states_needed.add("or");
        states_needed.add("id");
        states_needed.add("nv");
        states_needed.add("ut");
        states_needed.add("ca");
        states_needed.add("az");
        //设置每个广播站所覆盖的州
        HashSet<String> kone = new HashSet<>();
        kone.add("id");
        kone.add("nv");
        kone.add("ut");

        HashSet<String> ktwo = new HashSet<>();
        ktwo.add("wa");
        ktwo.add("id");
        ktwo.add("mt");

        HashSet<String> kthree = new HashSet<>();
        kthree.add("or");
        kthree.add("nv");
        kthree.add("ca");

        HashSet<String> kfour = new HashSet<>();
        kfour.add("nv");
        kfour.add("ut");

        HashSet<String> kfive = new HashSet<>();
        kfive.add("ca");
        kfive.add("az");

        //存储广播站和对应覆盖的州的键值对
        HashMap<String, HashSet<String>> stations = new HashMap<>();
        stations.put("one",kone);
        stations.put("two",ktwo);
        stations.put("three",kthree);
        stations.put("four",kfour);
        stations.put("five",kfive);

        HashSet<String> final_stations = new HashSet<>();

        String best_station = null;
        HashSet<String> states_covered = new HashSet<>();
        HashSet<String> covered = new HashSet<>();

        Set<Map.Entry<String, HashSet<String>>> entries = stations.entrySet();
        for (Map.Entry<String, HashSet<String>> entry : entries) {
            HashSet<String> states = entry.getValue();
            for (String state : states) {
                if(states_needed.contains(state)){
                covered.add(state);
                }
            }
            if(covered.size() > states_covered.size()){
                best_station = entry.getKey();
                states_covered = covered;
            }
            states_needed.remove(states_covered);
        }



    }
}
